package com.ruiyi.mapper;

import com.ruiyi.domain.User;
import com.ruiyi.dto.UserDto;
import com.ruiyi.dto.UserSearchDto;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper {

    //分页查询
    @Select("select u.*,u.dept_id as deptId,d.name,d.loc from user u inner join dept d on u.dept_id = d.id")
    List<User> selectUsersByPage();

    //添加客户信息
    int insertUser(UserDto userDto);

    //查询要添加的用户信息数据库表里面是否已经存在了
    @Select("select count(*) from user where username = #{username} and birthday = #{birthday} " +
            "and address = #{address} and sex = #{sex} and tel = #{tel}")
    int selectUsersIsExist(UserDto userDto);

    //添加的过程中去判断部门是否存在
    @Select("select count(*) from dept where id = #{deptId}")
    int selectDeptIsExist(UserDto userDto);

    //批量删除
    @Delete("delete from user where id in(${arg0})")
    int deleteManyUser(String id);

    //搜索客户信息
    List<User> selectUsersBySearch(UserSearchDto userSearchDto);

    //单个删除
    @Delete("delete from user where id = #{arg0}")
    int deleteOneUser(Long id);

    //修改客户信息
    int updateUser(UserDto userDto);

}
